<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('选择经理')" />
</head>
<body class="gray-bg">
<div class="col-sm-12 search-collapse">
	<form id="formId">
		<div class="select-list">
			<ul>
				<li>
					业务员编号：
					<input type="number" name="smNum"/>
				</li>
				<li>
					业务员名称：
					<input type="text" name="smName"/>
				</li>
				<li>
					业务员电话：
					<input type="text" name="smPhone"/>
				</li>
				<li>
					<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
					<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
				</li>
			</ul>
		</div>
	</form>
</div>
     <div class="container-div">
		 <input type="hidden" id="obj" th:value="${obj}">
		<div class="row">
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        $(function() {
			var sm_status = [[${@dict.getType('sm_status')}]];
			var options = {
				url: ctx + "salesman/salesman/list",
				showSearch: false,
				showRefresh: false,
				showToggle: false,
				showColumns: false,
				clickToSelect:true,
				columns: [{
					radio: true
				},
					{
						field : 'smNum',
						title : '业务员编号'
					},
					{
						field : 'smName',
						title : '业务员名称'
					},
					{
						field : 'smPhone',
						title : '业务员电话'
					},
					{
						field : 'department',
						title : '部门'
					},
					{
						field : 'argeaarea',
						title : '大区'
					},
					{
						field : 'branchoffice',
						title : '分公司'
					},
					{
						field : 'smStatus',
						title : '状态',
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(sm_status, value);
						}
					},
					{
						field : 'smAddtime',
						title : '添加时间'
					},
					{
						field : 'smNote',
						title : '备注',
						formatter:function (value, row, index) {
							return $.table.tooltip(value,7);
						}
					},
					]
			};
            $.table.init(options);
        });
        
        /* 添加用户-选择用户-提交 */
		function submitHandler(index, layero) {
			var smNum = $.table.selectColumns("smNum");
			var smName = $.table.selectColumns("smName");
			var smStatus = $.table.selectColumns("smStatus");

			if (smNum.length == 0) {
       			$.modal.alertWarning("请至少选择一条记录");
       			return;
       		}
			$.modal.close();
			//修改父页面值
			if ($("#obj").val() == 'xs'){
				parent.$("#sm_name2").val(smName);
				parent.$("#sm_num2").val(smNum);
			} else if ($("#obj").val() == 'yy'){
				parent.$("#sm_name1").val(smName);
				parent.$("#sm_num1").val(smNum);
			}


		}
    </script>
</body>
</html>